var url = serverPre + "/manager/yzt/v1/system/info"

var bsConf = {

    queryFormId: "dic-query-form",

    createFormId: "dic-create-form",

    updateFormId: "dic-update-form",

    tableID: "id",

    queryCols: 3,

    queryFloat: "right",

    voName: "dicInfo",

    queryConfigs:                   //页面头部查询form
        [
            {
                type: 'select',
                label: '系统标识：',
                name: 'systemSign',
                dataUrl: serverPre + "/manager/yzt/v1/system/info/?pageNo=1&pageSize=9999999&a=1",
                nameProperty: 'systemName',
                idProperty:'systemSign'
            },
        ],

    createConfigs:                  //新建form
        [
            {
                type: 'text',
                label: '父系统标识',
                name: 'parentId',
                default: '',
                verify: ''
            },
            {
                type: 'text',
                label: '系统标识',
                name: 'systemSign',
                default: '',
                verify: ''
            },
            {
                type: 'text',
                label: '公钥',
                name: 'publicKey',
                default: '',
                verify: '',
                readOnly:'readOnly'
            },
            {
                type: 'text',
                label: '私钥',
                name: 'privateKey',
                default: '',
                verify: '',
                readOnly:'readOnly'
            },
            {
                type: 'text',
                label: '系统名称',
                name: 'systemName',
                default: '',
                verify: ''
            },
            {
                type: 'text',
                label: '业务通知地址',
                name: 'serviceUrl',
                default: '',
                verify: ''
            },
            {
                type: 'text',
                label: '备注',
                name: 'remark',
                default: '',
                verify: ''
            }
        ],
    updateConfigs:                  //修改form
        [
            {
                type: 'text',
                label: '父系统标识',
                name: 'parentId',
                default: '',
                verify: ''
            },
            {
                type: 'text',
                label: '系统标识',
                name: 'systemSign',
                default: '',
                verify: ''
            },
            {
                type: 'text',
                label: '系统名称',
                name: 'systemName',
                default: '',
                verify: ''
            },
            {
                type: 'text',
                label: '业务通知地址',
                name: 'serviceUrl',
                default: '',
                verify: ''
            },
            {
                type: 'text',
                label: '是否使用',
                name: 'accessed',
                default: '',
                verify: ''
            },
            {
                type: 'text',
                label: '备注',
                name: 'remark',
                default: '',
                verify: ''
            }
        ],
    //列表内容
    tableCols: [
        {type: 'checkbox'}
        , {field: 'id', title: '序号', type: 'numbers'}
        , {field: 'parentId', width: '10%', title: '父系统标识'}
        , {field: 'systemSign', width: '10%', title: '系统标识'}
        , {field: 'publicKey', width: '10%', title: '公钥'}
        , {field: 'privateKey', width: '10%', title: '私钥'}
        , {field: 'secretKey', width: '10%', title: '验签码'}
        , {field: 'systemName', width: '10%', title: '系统名称'}
        , {field: 'remark', width: '10%', title: '备注'}
        , {field: 'serviceUrl', width: '10%', title: '业务通知地址'}
        , {fixed: 'right', width: 250, align: 'center', toolbar: '#barDemo'}
       /* ,{field:'action', width:'5%', title: '操作', templet: function(d){
                return "" +
                    "  <button dataid='" + d.id + "' onclick=\"update('" + d.id + "');\" class=\"layui-btn layui-btn-sm bs-button-update\">修改</button>\n" +
                    "";
            }}*/

    ],

}
var index
function update(id) {
    var content="新系统提示地址：<input type=\"text\" id=\"updataUrl\" style=\"width: 500px;height: 40px\">\n" +
        "<button class=\"layui-btn\"  onclick=\"updateNow('"+id+"')\">确定</button>\n" +
        "<button class=\"layui-btn\" onclick=\"closeThis()\">取消</button>\n" +
        "<div id=\"pageDiv\"></div>"
    index = layer.open({
        type: 1,
        content: content,
        area: ['60%', '30%'],
        success: function () {

        }})

}
function updateNow(id) {
    var id = id;
    var url = $("#updataUrl").val()
    $.ajax({
        type:"POST",
        url: serverPre + "/manager/yzt/v1/system/info/update",
         headers:{"token":getCookie("token")},
        data:{sysId:id,newUrl:url},
        dataType: "json",
        success: function(res) {
            if (res.code==0){
                layer.alert("修改成功")

            } else{
                layer.alert("修改失败")
            }
            layer.close(index)
            window.parent.location.reload();
        }
        })


}
function closeThis() {
    layer.close(index)
}